const RICH_TEXT_KEY = 'APTW_RICH_TEXT_DRAFT';

export const getDraft = () => {
  const text = sessionStorage.getItem(RICH_TEXT_KEY);
  return text ? JSON.parse(text) : null;
};

export const setDraft = (richText: Record<string, any>) => {
  sessionStorage.setItem(RICH_TEXT_KEY, JSON.stringify(richText));
  return getDraft();
};

export const clearDraft = () => {
  sessionStorage.removeItem(RICH_TEXT_KEY);
  return getDraft();
};
